﻿function DoSetFocus(obj)
{
	try
	{
		if (obj != null && obj.style.display != "none")
			obj.focus();
	}catch(e){}
}

function GetCookie(sName)
{
	// cookies are separated by semicolons
	var aCookie = document.cookie.split("; ");
	for (var i=0; i < aCookie.length; i++)
	{
		// a name/value pair (a crumb) is separated by an equal sign
		var aCrumb = aCookie[i].split("=");
		if (sName == aCrumb[0]) 
			return unescape(aCrumb[1]);
	}

	// a cookie with the requested name does not exist
	return null;
}

function ChangeLanguage(strLanguage, bRedirect)
{
	document.cookie = "Lang=" + strLanguage + "; path=/; expires=Fri, 31 Dec 2021 23:59:59 GMT;";
	if (bRedirect)
		window.location.href = window.location.href;
}

function DoBodyOnClick()
{
	if ($get(g_str_lblMessages) != null)
		$get(g_str_lblMessages).innerHTML = "";
    //document.body.onclick = null;
    hide_pnLeftMenu(true);
}

function SetBodyOnClick(nTime)
{
	if (nTime == null)
		nTime = 1000;
	window.setTimeout("document.body.onclick = DoBodyOnClick;", nTime);
}

function DisplayMessage(strError, strClassName) {
	if ($get(g_str_lblMessages) == null)
		return;
	if (strClassName == null)
		strClassName = "clsError";
    $get(g_str_lblMessages).className = strClassName;
	$get(g_str_lblMessages).innerHTML = strError;
	$get(g_str_lblMessages).style.display = "";
	SetBodyOnClick();
}

function DisplayMessageIn(strTarget, strMessage, strClassName, doSetBodyOnClick) {
	if (($get(strTarget) == null) && ($find(strTarget) == null)) //HTML and/or AJAX
		return;
	var target = ($get(strTarget) == null) ? $find(strTarget) : $get(strTarget);
	target.className = strClassName;
	target.innerHTML = strMessage;
	target.style.display = "";
	if(doSetBodyOnClick)
		SetBodyOnClick();
}


function onclick_imgPin2()
{
	if ($get(g_str_imgPin) == null)
		return;

	if ($get(g_str_imgPin).src.indexOf("pin_off") != -1)
	{
		$get(g_str_imgPin).src = $get(g_str_imgPin).src.replace("pin_off", "pin_on");
		$get('divMenu').style.display = 'none';
		$get('divMenu3').style.display = 'none';
		$get('divMenu2').style.display = '';
		document.cookie = "MenuPin=true; path=/; expires=Fri, 31 Dec 2021 23:59:59 GMT;";
	}
	else
	{
		$get(g_str_imgPin).src = $get(g_str_imgPin).src.replace("pin_on", "pin_off");
		$get('divMenu2').style.display = 'none';
		$get('divMenu').style.display = '';
		$get('divMenu3').style.display = '';
		document.cookie = "MenuPin=false; path=/; expires=Fri, 31 Dec 2021 23:59:59 GMT;";
	}
}
